package pl.edu.uj.tcs.blef.protocol;

import java.io.PrintWriter;
import java.net.Socket;

import pl.edu.uj.tcs.blef.server.Table;

public class ShowBetPoolRequestHandler extends AbstractTableHandler {

	public ShowBetPoolRequestHandler(Table table) {
		super(table);
	}

	@Override
	public void handle(Request request, Socket socket) {
		if(table.getGame() == null){
			try {
				Request r = new UnknownRequestErrorFactory().build(null, new NullRequestHandler());
				r.send(new PrintWriter(socket.getOutputStream()));
			} catch (Exception e){}
		} else {
			StringBuilder sb = new StringBuilder();
			sb.append("OK /show-bet-pool" + '\n');
			sb.append(table.getGame().getBetPool());
			try {
				String[] param = new String[1]; param[0] = sb.toString();
				Request r = new OKRequestFactory().build(param, new NullRequestHandler());
				r.send(new PrintWriter(socket.getOutputStream()));
			} catch (Exception e){}
		}
	}

}
